package com.shigu.agent.model.impl;

import com.shigu.agent.bo.AgentBO;
import com.shigu.agent.bo.OperateBO;
import com.shigu.agent.bo.RateBO;
import com.shigu.agent.bo.UserBO;
import com.shigu.agent.exceptions.YeepayException;
import com.shigu.agent.model.MoOperate;
import com.shigu.agent.model.MoUser;
import com.shigu.main4.common.util.BeanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;

/**
 * 运营账号
 */
@Component
@Scope("prototype")
public class MoOperateImpl extends MoUserImpl implements MoOperate{


    private OperateBO operateBO;

    public MoOperateImpl() {
    }

    public MoOperateImpl(OperateBO userinfo) {
        this.operateBO=userinfo;
    }

    public MoOperateImpl(Long userId) {
        super(userId);
    }

    @PostConstruct
    public void init() throws YeepayException {
        if (getUserId() == null&&operateBO!=null) {
            setUserId(createOne(operateBO));
        }
    }

    @Transactional(rollbackFor = Exception.class)
    public Long createOne(OperateBO userinfo) throws YeepayException {
        return super.createOne(userinfo);
    }

    @Override
    public Long createAgent(AgentBO agent) {

        return null;
    }

    @Override
    public void initAgentPwd(Long agentId, String password) {

    }

    @Override
    public void setAgentRate(Long agentId, RateBO rate) {

    }
}
